﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DecisionFramework.ServiceProtection
{
    /// <summary>
    /// Specifies the interface for a service protector.
    /// </summary>
    /// <remarks>
    /// A service protector provides a fluent interface 
    /// for ensuring key security requirements in order
    /// to perform a block of code.
    /// </remarks>
    public interface IServiceProtector
    {
        /// <summary>
        /// The mechanisms will need this security token to determine
        /// authentication and authorization. 
        /// </summary>
        string SecurityToken { get; set; }

        /// <summary>
        /// Specifies that the service will require a valid given
        /// security token in order to continue processing.
        /// </summary>
        /// <param name="securityToken">The security token to check validity.</param>
        /// <returns>This for fluent interface.</returns>
        IServiceProtector RequiresValidSecurityToken(string securityToken);

        /// <summary>
        /// Specifies that the principal associated with the security token
        /// will need the authorization action for the given optional toObject.
        /// </summary>
        /// <param name="action">The authorization action that performs the check.</param>
        /// <param name="toObject">Action will check access to this, optional, object.</param>
        /// <returns>This for fluent interface.</returns>
        IServiceProtector AndAuthorizedTo (IAuthorizationAction action, object toObject); 
        
        /// <summary>
        /// Specifies that the principal associated with the given security token 
        /// will need to be of the level of the given role type.
        /// </summary>
        /// <param name="roleType">The role type level required.</param>
        /// <returns>This for fluent interface.</returns>
        IServiceProtector AndRequiresRoleType(RoleType roleType);

        /// <summary>
        /// All other statements must be true in order to perform
        /// the given service action (block of code).
        /// </summary>
        /// <param name="action">The service action (block of code).</param>
        void InOrderToPerform(Action action);
    }
}
